package com.dm.service;

import com.dm.dao.MapperDB01;
import com.dm.dao.MapperDB02;
import com.dm.model.UserT;
import com.dm.model.Users;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * [迁移Service].
 * [可以编写具体数据迁移的逻辑]
 * <h3>version info：</h3><br>
 * v1.0 2020年09月24日 Eric Wang创建<br>
 * <br>
 * @author Eric Wang
 * @version 1.0
 * @since JDK 1.8
 */
@Service
public class MigrationService {
    private static Logger logger = LoggerFactory.getLogger(MigrationService.class);
    @Autowired
    private MapperDB01 mapperdb01;

    @Autowired
    private MapperDB02 mapperdb02;


    public void DataMigrationExm(){
        //第一个库取数据
        List<UserT> usersList = mapperdb01.getAllUser();
        usersList.forEach(user->{
            logger.debug("mapperdb01 users table" + user.getUserName());
        });

        //第一个库取数据，这可以改成第二个库插入数据
        List<Users> userTList = mapperdb02.getAllUser();
        userTList.forEach(user->{
            logger.debug("mapperdb02 userT table" + user.getName());
        });
    }
}
